<%
  #File:    /app/views/manage/messages/_form.rhtml
  #Author:  Andrew Stone
  #Created: 09.19.2006
  title = "Creating message" 
  title = "Updating message id: #{@message.id}" if @message.id
  action = "create"
  action = "update" if @message.id
%> 

<%=javascript_include_tiny_mce %>
<%=tiny_mce%>

<%=error_messages_for("message")%>

<%=start_form_tag(:action => action)%>
<%=start_large_div_wrapper%>

  <div id="page_title"><%=title%></div>
  <div id="large">
    <table>
      <tbody>
        <tr>
          <td class="req_label">* Title:</td>
          <td class="data"><%=text_field("message","title")%></td>
        </tr>
        <tr>
          <td class="req_list_label">* Details:</td>
          <td class="list_data"><%=text_area("message","details",{:cols => 60, :rows => 6})%></td>
        </tr>
        <tr>
          <td class="req_label">* Expires On:</td>
          <td class="date_select"><%=date_select("message","expires_on", :start_year => 2006)%></td>
        </tr>
        <tr>
          <td class="list_label">Referenced Page:</td>
          <td class="data">
            <select id="message_page_id" name="message[page_id]">
              <option/>
              <%
                pgs = Page.list_by_folder
                pgs.each do |pg|
                  selected = ""
                  selected = " selected='selected' " if pg[:id] == @message.page_id %>
                  <option value="<%=pg[:id]%>" <%=selected%>><%=pg[:name]%></option>
              <%
                end
              %>
            </select>
          </td>
        </tr>
        <%=user_group_restrictions(@message)%>
      </tbody>
    </table>
    <%=hidden_field("message","id")%>
    <div id="actions">
      <%=submit_tag("Cancel")%>
      <%=submit_tag(action.capitalize)%>
    </div>
  </div>

<%=end_div_wrapper%>
<%=end_form_tag%>
